
****************************************************************************
** Table 4a: District-propogation (based on 500 km distance --- discrete)
****************************************************************************

use "$datadir\ewallet\maindata.dta", clear

	forval i = 2/4{
		local j = `i'*0.1
		g min_distance_dummy_500`i' = (min_distance_hub_500 > `j')
		g post`i'Xdist500 = post*min_distance_dummy_500`i'
	}
	
	g postXdistdummy = post2Xdist500
	label var postXdistdummy " $ \text{(Distance to hub)}_{d} $ $ \times $ Post"

	replace postXdistdummy = post2Xdist500
	reghdfe  logamount postXdistdummy if $filters, a($fe $dist_controls##i.time_id i.state_id##i.time_id) cluster(district_id)
	outreg2 using "$outputdir_tab\Table_H_11", tex(frag) ctitle(" $ \delta $ = 200 ") dec(3) bracket label addtext(District f.e. , $\checkmark$ , Month f.e. , $\checkmark$ , District Controls $\times$ Month f.e., $\checkmark$ , State $\times$ Month f.e., $\checkmark$) nocons nonotes stats(coef se)  replace
	replace postXdistdummy = post3Xdist500
	reghdfe  logamount postXdistdummy  if $filters, a($fe $dist_controls##i.time_id i.state_id##i.time_id) cluster(district_id)
	outreg2 using "$outputdir_tab\Table_H_11", tex(frag) ctitle("log(amount)") dec(3) bracket label addtext(District f.e. , $\checkmark$ , Month f.e. , $\checkmark$ , District Controls $\times$ Month f.e., $\checkmark$ , State $\times$ Month f.e., $\checkmark$) nocons nonotes stats(coef se)  append
	replace postXdistdummy = post4Xdist500
	reghdfe  logamount postXdistdummy  if $filters, a($fe $dist_controls##i.time_id i.state_id##i.time_id) cluster(district_id)
	outreg2 using "$outputdir_tab\Table_H_11", tex(frag) ctitle("log(amount)") dec(3) bracket label addtext(District f.e. , $\checkmark$ , Month f.e. , $\checkmark$ , District Controls $\times$ Month f.e., $\checkmark$ , State $\times$ Month f.e., $\checkmark$) nocons nonotes stats(coef se)  append
	
	foreach var in lognumfirms lognewfirms {
		replace postXdistdummy = post2Xdist500
		reghdfe  `var' postXdistdummy if $filters, a($fe $dist_controls##i.time_id i.state_id##i.time_id) cluster(district_id)
		outreg2 using "$outputdir_tab\Table_H_11", tex(frag) ctitle(" $ \delta $ = 200 ") dec(3) bracket label addtext(District f.e. , $\checkmark$ , Month f.e. , $\checkmark$ , District Controls $\times$ Month f.e., $\checkmark$ , State $\times$ Month f.e., $\checkmark$ ) nocons nonotes stats(coef se)  append
		replace postXdistdummy = post3Xdist500
		reghdfe  `var' postXdistdummy  if $filters, a($fe $dist_controls##i.time_id i.state_id##i.time_id) cluster(district_id)
		outreg2 using "$outputdir_tab\Table_H_11", tex(frag) ctitle("log(amount)") dec(3) bracket label addtext(District f.e. , $\checkmark$ , Month f.e. , $\checkmark$ , District Controls $\times$ Month f.e., $\checkmark$ , State $\times$ Month f.e., $\checkmark$) nocons nonotes stats(coef se)  append
		replace postXdistdummy = post4Xdist500
		reghdfe  `var' postXdistdummy  if $filters, a($fe $dist_controls##i.time_id i.state_id##i.time_id) cluster(district_id)
		outreg2 using "$outputdir_tab\Table_H_11", tex(frag) ctitle("log(amount)") dec(3) bracket label addtext(District f.e. , $\checkmark$ , Month f.e. , $\checkmark$ , District Controls $\times$ Month f.e., $\checkmark$ , State $\times$ Month f.e., $\checkmark$) nocons nonotes stats(coef se)  append
	}
	